using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
namespace MicroMsg.UI.UserContrl
{
	public static class TreeExtensions
	{
		public static IEnumerable<DependencyObject> Descendants(this DependencyObject item)
		{
			TreeExtensions.<Descendants>d__0 <Descendants>d__ = new TreeExtensions.<Descendants>d__0(-2);
			<Descendants>d__.<>3__item = item;
			return <Descendants>d__;
		}
		public static IEnumerable<DependencyObject> DescendantsAndSelf(this DependencyObject item)
		{
			TreeExtensions.<DescendantsAndSelf>d__a <DescendantsAndSelf>d__a = new TreeExtensions.<DescendantsAndSelf>d__a(-2);
			<DescendantsAndSelf>d__a.<>3__item = item;
			return <DescendantsAndSelf>d__a;
		}
		public static IEnumerable<DependencyObject> Ancestors(this DependencyObject item)
		{
			TreeExtensions.<Ancestors>d__10 <Ancestors>d__ = new TreeExtensions.<Ancestors>d__10(-2);
			<Ancestors>d__.<>3__item = item;
			return <Ancestors>d__;
		}
		public static IEnumerable<DependencyObject> AncestorsAndSelf(this DependencyObject item)
		{
			TreeExtensions.<AncestorsAndSelf>d__15 <AncestorsAndSelf>d__ = new TreeExtensions.<AncestorsAndSelf>d__15(-2);
			<AncestorsAndSelf>d__.<>3__item = item;
			return <AncestorsAndSelf>d__;
		}
		public static IEnumerable<DependencyObject> Elements(this DependencyObject item)
		{
			TreeExtensions.<Elements>d__1b <Elements>d__1b = new TreeExtensions.<Elements>d__1b(-2);
			<Elements>d__1b.<>3__item = item;
			return <Elements>d__1b;
		}
		public static IEnumerable<DependencyObject> ElementsBeforeSelf(this DependencyObject item)
		{
			if (Enumerable.FirstOrDefault<DependencyObject>(item.Ancestors()) != null)
			{
				using (IEnumerator<DependencyObject> enumerator = Enumerable.First<DependencyObject>(item.Ancestors()).Elements().GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						DependencyObject current = enumerator.get_Current();
						if (current.Equals(item))
						{
							break;
						}
						yield return current;
					}
				}
			}
			yield break;
		}
		public static IEnumerable<DependencyObject> ElementsAfterSelf(this DependencyObject item)
		{
			TreeExtensions.<ElementsAfterSelf>d__28 <ElementsAfterSelf>d__ = new TreeExtensions.<ElementsAfterSelf>d__28(-2);
			<ElementsAfterSelf>d__.<>3__item = item;
			return <ElementsAfterSelf>d__;
		}
		public static IEnumerable<DependencyObject> ElementsAndSelf(this DependencyObject item)
		{
			TreeExtensions.<ElementsAndSelf>d__2f <ElementsAndSelf>d__2f = new TreeExtensions.<ElementsAndSelf>d__2f(-2);
			<ElementsAndSelf>d__2f.<>3__item = item;
			return <ElementsAndSelf>d__2f;
		}
		public static IEnumerable<DependencyObject> Descendants<T>(this DependencyObject item)
		{
			return Enumerable.Cast<DependencyObject>(Enumerable.Where<DependencyObject>(item.Descendants(), (DependencyObject dependencyObject_0) => dependencyObject_0 is T));
		}
		public static IEnumerable<DependencyObject> ElementsBeforeSelf<T>(this DependencyObject item)
		{
			return Enumerable.Cast<DependencyObject>(Enumerable.Where<DependencyObject>(item.ElementsBeforeSelf(), (DependencyObject dependencyObject_0) => dependencyObject_0 is T));
		}
		public static IEnumerable<DependencyObject> ElementsAfterSelf<T>(this DependencyObject item)
		{
			return Enumerable.Cast<DependencyObject>(Enumerable.Where<DependencyObject>(item.ElementsAfterSelf(), (DependencyObject dependencyObject_0) => dependencyObject_0 is T));
		}
		public static IEnumerable<DependencyObject> DescendantsAndSelf<T>(this DependencyObject item)
		{
			return Enumerable.Cast<DependencyObject>(Enumerable.Where<DependencyObject>(item.DescendantsAndSelf(), (DependencyObject dependencyObject_0) => dependencyObject_0 is T));
		}
		public static IEnumerable<DependencyObject> Ancestors<T>(this DependencyObject item)
		{
			return Enumerable.Cast<DependencyObject>(Enumerable.Where<DependencyObject>(item.Ancestors(), (DependencyObject dependencyObject_0) => dependencyObject_0 is T));
		}
		public static IEnumerable<DependencyObject> AncestorsAndSelf<T>(this DependencyObject item)
		{
			return Enumerable.Cast<DependencyObject>(Enumerable.Where<DependencyObject>(item.AncestorsAndSelf(), (DependencyObject dependencyObject_0) => dependencyObject_0 is T));
		}
		public static IEnumerable<DependencyObject> Elements<T>(this DependencyObject item)
		{
			return Enumerable.Cast<DependencyObject>(Enumerable.Where<DependencyObject>(item.Elements(), (DependencyObject dependencyObject_0) => dependencyObject_0 is T));
		}
		public static IEnumerable<DependencyObject> ElementsAndSelf<T>(this DependencyObject item)
		{
			return Enumerable.Cast<DependencyObject>(Enumerable.Where<DependencyObject>(item.ElementsAndSelf(), (DependencyObject dependencyObject_0) => dependencyObject_0 is T));
		}
	}
}
